//
//  MainTabBarController.m
//  jiajia
//
//  Created by rujia chen on 16/5/1.
//  Copyright © 2016年 sunrisin. All rights reserved.
//

#import "MainTabBarController.h"
#import "UIViewController+SSO.h"

@implementation MainTabBarController

- (void)viewDidLoad {
    [self doLogInWithID:@"15026587203" andPassword:@"321" successBlock:^(NSURLSessionTask *task, NSDictionary *response) {
        
        EMChatText *txtChat = [[EMChatText alloc] initWithText:@"要发送的消息"];
        EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithChatObject:txtChat];
        EMMessage *message = [[EMMessage alloc] initWithReceiver:@"crj" bodies:@[body]];
        message.messageType = eMessageTypeChat;
        
        [[EaseMob sharedInstance].chatManager asyncSendMessage:message progress:nil prepare:^(EMMessage *message, EMError *error) {
            
        } onQueue:nil completion:^(EMMessage *message, EMError *error) {
            
        } onQueue:nil];
        
    } failBlock:^(NSURLSessionTask *task, NSInteger errcode, NSString *errmsg) {
        
    } exceptionBlock:^(NSURLSessionTask *task, NSError *error) {
        
    }];
    
//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//        [self doLogOutWithSuccessBlock:^(NSURLSessionTask *task, NSDictionary *response) {
//        } failBlock:nil exceptionBlock:nil];
//    });
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
}

- (void)jj_addNotificationObserver:(NSNotificationCenter *)notificationCenter {
    [notificationCenter addObserver:self selector:@selector(networkAction:) name:NCNetworkStatusChanged object:nil];
}

#pragma mark - notification handler

- (void)networkAction:(NSNotification*)notification {
    NSLog(@"%@", notification.object);
}

@end
